﻿@{
    ViewBag.Title = "已买到的商品";
    Layout = "~/Views/Shared/_MemberCenterLayout.cshtml";
}
@section Styles
{
    <link href="../../Content/jquery-ui.css" rel="stylesheet" type="text/css" />
  
}
@section Scripts
{
    <script src="../../Scripts/jquery/jquery-ui.min.js" type="text/javascript"></script>
    <script src="../../Scripts/jquery/ui.datepicker-zh-CN.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(function () {
            $("#J_BeginTime").datepicker();
            $("#J_EndTime").datepicker();
            GetUserOrder();
            $("#btnSearch").click(Search);

            $("#J_TradeStatusHandle").change(function () {
                jsSelectItemByValue("J_TradeStatus", this.options[this.selectedIndex].value);
                Search();
            }
            );
        });
        function jsSelectItemByValue(Selectid, objItemvalue) {

            var objSelect = document.getElementById(Selectid);
           
            for (var i = 0; i < objSelect.options.length; i++) {

                if (objSelect.options[i].value == objItemvalue) {
                    objSelect.options[i].selected = true;
                    break;
                }
            }


        }
        function Search() {
            $("#currentIndex").val(1);
            GetUserOrder();
        }
        function GetUserOrder() {

            $.post("/Trade/GetUserOrder", $("#search").serialize(), creatUI, "json");
        }
        function GetUserOrderbyindex(pageindex) {
            $("#currentIndex").val(pageindex);
            GetUserOrder();
        }
        function GetUserOrderbyindex() {

            if ($("#J_PageNum").val() != "") {

                $("#currentIndex").val($("#J_PageNum").val());
                GetUserOrder();
            }
        }
        function creatUI(data) {

            var dataList = data.list;


            var tboby = "";
            var paget = "";
            var pageb = "";

            var currentIndex = parseInt(data.currentIndex);
            $("#currentIndex").val(data.currentIndex);
            var totalPages = parseInt(data.totalPages);
            $("#OrderList tbody").slice(1).remove();

            if (dataList != null && dataList.length > 0) {

                for (var i = 0; i < dataList.length; i++) {
                    var order = dataList[i];

                    tboby += '<tbody data-status="' + order.STATE + '" data-orderid="' + order.OrderNO + '">';
                    tboby += '<tr><td colspan="9">  <div class="blank"></div></td></tr>';
                    tboby += '<tr class="order-hd">';
                    tboby += '<td colspan="9">';
                    tboby += '<input type="checkbox" name="biz_order_id" class="selector" style="float: left;">';
                    tboby += ' <div class="basic-info">';
                    tboby += '<span class="order-num">';
                    tboby += '<label>订单编号：' + order.OrderNO + '</label>&nbsp;&nbsp;&nbsp;</span> <span class="deal-time">成交时间：' + order.AddTime + '</span></div>';
                    tboby += ' </td>';
                    tboby += '</tr>';
                    var orderitem = order.items;
                    for (var j = 0; j < orderitem.length; j++) {
                        var item = orderitem[j];
                        tboby += '<tr class="order-item">';
                        tboby += '<td class="item" colspan="2">';
                        tboby += '<div class="pic-info">';

                        tboby += '<a href="/Detail/item?id=' + item.GID + '" title="查看宝贝详情" target="_blank" hidefocus="true"><img src="' + item.SmallImgUrl + '" alt="查看宝贝详情"></a>';
                        tboby += '</div>';
                        tboby += '<div class="txt-info">';
                        tboby += '<div class="desc">';
                        tboby += '<a target="_blank" title="查看宝贝详情" href="/Detail/item?id=' + item.GID + '">' + item.ProdTitle + '</a> <span class="good-icons">';
                        tboby += '</span></div>';
                        tboby += '<div class="props">';
                        if (item.ColorName != "") {
                            tboby += '<span>颜色: <em>' + item.ColorName + ' </em></span>';
                        }

                        if (item.SizeName != "") {
                            tboby += '<span>尺寸: <em>' + item.SizeName + ' </em></span>';
                        }
                        tboby += '</div></div>';
                        tboby += '</td>';

                        tboby += '<td class="price">' + item.OPRICE.toFixed(2) + '</td>';
                        tboby += '<td title="' + item.ONUM + '"> ' + item.ONUM + '</td>';
                        tboby += '<td><a url="#;" target="_blank" title="">投诉维权</a></td>';
                        if (j == 0) {
                            tboby += ' <td  rowspan="' + orderitem.length + '"><strong>' + order.AMOUNT.toFixed(2) + '</strong><div class="post-info">(含<span>快递</span>:<span>' + order.YunFei.toFixed(2) + '</span>)</div>';
                            tboby += ' <div><a target="_blank" href="#;" title="查看物流">查看物流</a></div>';
                            tboby += '</td>';
                            tboby += '<td class="trade-status" rowspan="' + orderitem.length + '">';
                            tboby += '<a class="J_MakePoint status todo"  target="_blank" >等待买家付款 </a>';
                            tboby += '<span><a class="detail-link J_MakePoint"  target="_blank" href="/detail/orderDetail?bizOrderId=' + order.ID + '">订单详情</a></span>';
                            tboby += '</td>';
                            tboby += '<td class="operate" rowspan="' + orderitem.length + '">';
                            tboby += '<span class="skin-orange"><a class="small-btn J_MakePoint button"  target="_blank">付款</a></span>';
                            tboby += '<a class="J_CancelOrderTg J_MakePoint">取消订单</a>';
                            tboby += '</td>';
                            tboby += '<td class="other" rowspan="' + orderitem.length + '">';
                            tboby += '<a class="J_DelOrder J_MakePoint" >删除</a>';
                            tboby += '</td>';
                        }
                        tboby += '</tr> ';
                    }
                }


                var yu = Math.floor(currentIndex / 6);
                if (totalPages > 0) {
                    if (currentIndex == 1) {
                        paget += '<li class="prev-page"><a class="disabled" href="#;"></a></li>';

                    } else {
                        var prevdindex = currentIndex - 1;
                        paget += '<li onclick="GetUserOrderbyindex(' + prevdindex + ')" class="prev-page"><a  href="#;"></a></li>';
                    }
                    if (currentIndex == totalPages) {
                        paget += '<li class="next-page"><a class="disabled" href="#;"></a></li>';
                    }
                    else {

                        paget += '<li onclick="GetUserOrderbyindex(' + (currentIndex + 1).toString() + ')" class="next-page"><a   href="#;"></a></li>';

                    }

                    for (var i = 6 * yu + 1; i <= totalPages; i++) {
                        if (currentIndex == i) {

                            pageb += '<li class="current"><a href="#;">' + i + '</a></li>';
                        }
                        else {
                            pageb += '<li onclick="GetUserOrderbyindex(' + i + ')"><a href="#;">' + i + '</a></li>';
                        }
                        if (i >= 6 * (yu + 1)) {
                            pageb += '<li ><a href="#;">...</a></li>';
                            break;
                        }
                    }
                    pageb += ' <li><span>&nbsp;共' + totalPages + '页&nbsp;&nbsp;</span></li>';
                    pageb += '<li><span>到第<input id="J_PageNum" type="text" maxlengh="4" size="2" name="pageNum" /><span>&nbsp;页</span>';
                    pageb += '  <input id="J_JumpTo" onclick="GetUserOrderbyindex()" class="J_MakePoint" type="button" value="确定">';
                    pageb += ' </span></li>';




                }

            }
            else {
                tboby += '<tbody class="msg">';
                tboby += '<tr> <td colspan="9">';
                tboby += '<div class="no-result">没有符合条件的宝贝，请尝试其他搜索条件。 </div>';
                tboby += ' </td></tr>';
                tboby += ' </tbody>';
            }
            $("#OrderList tbody").after(tboby);

            $(".page-nav").html(paget)
            $(".page-navb").html(pageb)
        }

    </script>
}
<div class="main pageWidth pb">
    @{Html.RenderAction("TopNav", "Member", new { pageType = 1 });}
    <div class="clearself">
        <div class="left">
            @{Html.RenderAction("MemberMenu", "Member", new { pageType = 1 });}
        </div>
        <div class="right">
            <div class="position">
                <a href="#;">我是买家</a> &gt; <a href="#;">交易管理</a> &gt; 已买到的商品
            </div>
             
            <div class="infoWrap">
                <form action="list_bought_items" id="search" method="post">
                <table border="0" cellpadding="0" cellspacing="0" class="InfoTb" id="searchWrap">
                    <tr>
                        <td colspan="2">
                            宝贝名称：<input id="J_BaobeiName" type="text" maxlength="30" value="" name="auctionTitle"
                                size="50">
                        </td>
                        <td width="240">
                            订单状态：<select id="J_TradeStatus" class="J_NiceSelect" name="auctionStatus">
                                <option value="0">全部</option>
                                <option value="1">等待买家付款</option>
                                <option value="2">买家已付款</option>
                                <option value="3">卖家已发货</option>
                                <option value="5">交易成功</option>
                                <option value="6">交易关闭</option>
                                <option value="4">退款中的订单</option>
                            </select>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2" width="240">
                            成交时间：从
                            <input id="J_BeginTime" type="text" value="" name="bizOrderTimeBegin" size="10">
                            到
                            <input id="J_EndTime" type="text" value="" name="bizOrderTimeEnd" size="10">
                        </td>
                        <td width="240">
                            评价状态：<select id="J_ReviewStatus" class="J_NiceSelect" name="commentStatus">
                                <option value="0">全部</option>
                                <option value="1">需我评价</option>
                                <option value="2">我已评价</option>
                                <option value="3">对方已评</option>
                                <option value="4">双方已评</option>
                            </select>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="3" align="right">
                            <input id="currentIndex" value="1" name="currentIndex" type="hidden" />
                            <input type="button" id="btnSearch" class="btn" value="搜索" />
                        </td>
                    </tr>
                </table>
                </form>
                <div class="tool-toggle">
                    <span class="show" id="showsearch"></span>
                </div>
            </div>
            <div class="dataWrap">
            <div class="item-list">
						<ul>
							<li class="current"><a  href="#;">近三个月订单</a></li>
							<li><a href="#;">等待买家付款</a></li>
							<li><a href="#;">等待发货</a></li>
   							<li><a href="#;">已发货</a></li>
							<li><a href="#;">退款中</a></li>
							<li><a href="#;">需要评价</a></li>
							<li><a href="#;">成功的订单</a></li>
							<li><a href="#;">关闭的订单</a></li>
							<li><a href="#;">三个月前订单</a></li>
						</ul>	
				</div>
                <div class="listWrap">
                    <table id="OrderList" border="0" cellpadding="0" cellspacing="0" class="listtb">
                        <thead>
                            <tr>
                                <th width="30">
                                </th>
                                <th class="item">
                                    宝贝
                                </th>
                                <th class="price">
                                    单价(元)
                                </th>
                                <th class="num">
                                    数量
                                </th>
                                <th class="trouble">
                                    售后
                                </th>
                                <th class="order-price">
                                    实付款(元)
                                </th>
                                <th class="trade-status">
                                    <div class="trade-status">
                                        <select id="J_TradeStatusHandle">
                                            <option value="0">交易状态</option>
                                            <option value="1">等待买家付款</option>
                                            <option value="2">买家已付款</option>
                                            <option value="3">卖家已发货</option>
                                            <option value="5">交易成功</option>
                                            <option value="6">交易关闭</option>
                                            <option value="4">退款中的订单</option>
                                        </select>
                                    </div>
                                </th>
                                <th class="remark">
                                    交易操作
                                </th>
                                <th class="other">
                                    其它操作
                                </th>
                            </tr>
                        </thead>
                        <tbody>
                            <tr>
                                <td colspan="9">
                                    <div class="operations">
                                        <ul class="page-nav">
                                        </ul>
                                        <input type="checkbox" class="selector"><label>全选</label>
                                        <a class="MakePoint" href="#;">批量确认收货</a> <span style="display: inline"></span>
                                    </div>
                                </td>
                            </tr>
                        </tbody>
                        <tfoot>
                            <tr>
                                <tr>
                                    <td colspan="9">
                                        <div class="blank">
                                        </div>
                                    </td>
                                </tr>
                                <td colspan="9">
                                    <div class="operations">
                                        <ul class="page-navb">
                                        </ul>
                                    </div>
                                </td>
                            </tr>
                        </tfoot>
                    </table>
                </div>
            </div>
           
        </div>
    </div>
</div>
